package com.lizhiyu.flink.demo2_source;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.Arrays;

/**
 * Flink 创建数据源 通过java对象信息
 */
public class JavaSource {

    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment evn = StreamExecutionEnvironment.getExecutionEnvironment();
        evn.setParallelism(1);
        DataStreamSource<String> ds1 = evn.fromElements("1", "2", "3");
        ds1.print();

        DataStreamSource<String> ds2 = evn.fromCollection(Arrays.asList("spring", "java", "kafka"));
        ds2.print();

        DataStreamSource<Long> ds3 = evn.fromSequence(1, 10);
        ds3.print();
        evn.execute();
    }
}
